﻿import mx.utils.Delegate;

//This class loads an XML file and recursively converts the XML elements into strings that are dynamically attached to this object which can be retrieved at a later time.

class arkadium.TXTConfigFile
{
	private var _fnCallBackFunction:Function;
	private var _cTXTFile:LoadVars
		
	public function TXTConfigFile()
	{
		
		
	}
	
	public function loadConfigFile( oCallerObject:Object, fnCallerFunction:Function, sFileURL:String )
	{
		
		_cTXTFile = new LoadVars();
		_fnCallBackFunction = Delegate.create( oCallerObject, fnCallerFunction );
		_cTXTFile.onLoad = Delegate.create(this,configFileLoaded);
		_cTXTFile.load(sFileURL);
	}
	
	private function configFileLoaded( bSuccess:Boolean )
	{
		_fnCallBackFunction.apply( null, [ bSuccess ] );
	}

	public function getData( sVariableName:String ):String
	{
		if(_cTXTFile[sVariableName] == undefined) return(this[sVariableName]);
		return(_cTXTFile[sVariableName]);
	}
	
	public function setData ( sVarName:String, oVarValue:Object ){
		_cTXTFile[sVarName] = oVarValue
	}

}
